import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class code3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(),m = in.nextInt();
        char[][] arr = new char[n+1][m+1];
        for(int i=1;i<n+1;i++) {
            char[] str = in.next().toCharArray();
            for(int j=1;j<m+1;j++) {
                arr[i][j] = str[j-1];
            }
        }
        int[][] dp = new int[n+1][m+1];
        for(int i=1;i<n+1;i++) {
            for(int j=1;j<m+1;j++) {
                int t = 0;
                if(arr[i][j]=='l') t = 4;
                else if(arr[i][j]=='o') t = 3;
                else if(arr[i][j]=='v') t = 2;
                else if(arr[i][j]=='e') t = 1;
                dp[i][j] = t+Math.max(dp[i-1][j],dp[i][j-1]);
            }
        }
        System.out.print(dp[n][m]);
    }
}
